package com.star.carserviceapi.domain.result;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;

import com.star.carserviceapi.domain.CarFeatureInfo;
import com.star.carserviceapi.domain.result.base.BaseResult;

public class QryCarModelResult extends
		BaseResult<LinkedHashMap<String, LinkedHashMap<String, String>>> {

	private LinkedList<CarFeatureInfo> mCars = new LinkedList<CarFeatureInfo>();

	public LinkedList<CarFeatureInfo> getCars() {
		return mCars;
	}

	@Override
	protected void packing(
			LinkedHashMap<String, LinkedHashMap<String, String>> data) {

		for (Iterator<String> it = data.keySet().iterator(); it.hasNext();) {
			String key = it.next();

			CarFeatureInfo year = new CarFeatureInfo();
			year.setIndexName(key);
			year.setIsGroup(true);
			mCars.add(year);

			LinkedHashMap<String, String> temp = data.get(key);

			for (Iterator<String> it2 = temp.keySet().iterator(); it2.hasNext();) {
				String carName = temp.get(it2.next());

				CarFeatureInfo item = new CarFeatureInfo();

				item.setIsGroup(false);
				item.setModel(carName);
				item.setYear(key);
				
				mCars.add(item);
			}

		}

	}

}
